﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace pforumaspwf
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //SqlConnection conn = new SqlConnection("server=PANDEPICPC\\PSQL;uid=pandaforum;pwd=123;database=pandaforum");
            SqlConnection conn = new SqlConnection("server=localhost\\PSQL;uid=pandaforum;pwd=123;database=pandaforum");

            DataSet ds = new DataSet();
            SqlDataAdapter cmd = new SqlDataAdapter("SELECT * FROM users", conn);
            cmd.Fill(ds, "users");

            testgrid.DataSource=ds.Tables["users"].DefaultView;
            testgrid.DataBind();
            textbox1.Text = ds.Tables["users"].Rows[0]["birthdate"].ToString();
        }

        public DataSet GetDataSet(SqlConnection conn, string SQL)
        {
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = SQL;
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            conn.Open();
            da.Fill(ds);
            conn.Close();

            return ds;
        }
    }
}